﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using RestSharp;
using XingNet.Web.Communication.Base;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;

namespace XingForOutlook
{
    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
          XingNetTokenHandler _TokenHandler;
          string ConsumerKey = "f1853ea04d2e15b12b29";
          string ConsumerSecret = "11d35f8a2fa449683059f3e18c4c3e6262d362b8";
          Uri CallbackUrl;
          //Create the TokenHandler
          _TokenHandler = new XingNetTokenHandler(ConsumerKey, ConsumerSecret);



          var client = XingBaseClient.GetClient(_TokenHandler, "", XingBaseClient.RequestMode.RequestToken);
          var request = new RestRequest("v1/request_token", Method.POST);
          var response = client.Execute(request);


          //var qs = HttpUtility.ParseQueryString(response.Content);
          //_TokenHandler.Access_Token = qs["oauth_token"];
          //_TokenHandler.Access_Token_Secret = qs["oauth_token_secret"];

          //request = new RestRequest("/v1/authorize");
          //request.AddParameter("oauth_token", _TokenHandler.Access_Token);
          //var url = client.BuildUri(request).ToString();
          //Response.Redirect(url);

          //return null;
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }

        #region VSTO generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }
        
        #endregion
    }
}
